function M = confusion_matrix(prd_Y, act_Y)

prd_Z_hold = repmat( 1: length( unique( act_Y ) ), size( act_Y, 1 ), 1 );
prd_Z = bsxfun( @eq, prd_Z_hold, prd_Y );

act_Z_hold = repmat( 1: length( unique( act_Y ) ), size( act_Y, 1 ), 1 );
act_Z = bsxfun( @eq, act_Z_hold, act_Y );

M = transpose ( double ( act_Z ) ) * double( prd_Z ) ; 
M = M / ( sum ( sum ( M ) ) ); 

%save -ascii confusion.txt M

plotnumeric( M ); 

%most_confused = max( max ( M.* ~eye( size( M, 1 ) ) ) ); 

%[ y_conf, h_x_conf ] = ind2sub( size ( M ), find( M == most_confused ) ); 

%print -djpeg plot_3.2.jpg
